<template>
  <el-card shadow="never" class="mt-8px">
    <template #header>
      <div class="h-3 flex justify-between">
        <span>{{title}}</span>
        <!-- <el-link
          type="primary"
          :underline="false"
          class="all-records-link"
          @click="handleAllRecordsClick"
        >
          更多
        </el-link> -->
      </div>
    </template>
    <el-skeleton :loading="loading" animated>
      <el-row :gutter="20">
        <el-col
          v-for="(item, index) in personnelData"
          :key="`personnel-${index}`"
          :xl="6"
          :lg="8"
          :md="6"
          :sm="12"
          :xs="12"
        >
          <div class="personnel-item">
            <div class="personnel-count">
              <strong>{{ item.count }}</strong> {{ unit }}
            </div>
            <div class="personnel-status">
              {{ item.status }}
            </div>
          </div>
        </el-col>
      </el-row>
    </el-skeleton>
  </el-card>
</template>

<script lang="ts" setup>
import { ref, reactive } from 'vue'
import { useRouter } from 'vue-router'
// 接收父组件传递的 props
defineProps({
  personnelData: {
    type: Array,
    required: true
  },
  loading: {
    type: Boolean,
    required: true
  },
  title: {
    type: String,
    required: true
  },
  unit: {
    type: String,
    required: true
  }
})
const router = useRouter()
// 点击“全部记录”按钮的事件
const handleAllRecordsClick = () => {
  router.push('attendance/employee-archive')
}
</script>

<style scoped>
.personnel-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  background-color: #fff;
  transition: all 0.3s;
}

.personnel-item:hover {
  /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-4px); */
}

.personnel-count {
  font-size: 16px;
  color: #333;
  margin-bottom: 8px;
}

.personnel-count strong {
  font-weight: bold;
  font-size: 20px;
}

.personnel-status {
  font-size: 14px;
  color: #666;
}
</style>